.class public Lcom/netease/newsreader/util/GroupListView;
.super Lcom/netease/newsreader/view/PullRefreshListView;
.source "GroupListView.java"

# interfaces
.implements Landroid/widget/AbsListView$OnScrollListener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/netease/newsreader/util/GroupListView$TopViewCallback;
    }
.end annotation


# instance fields
.field private mCurrentGroup:I

.field private mGroupAdapter:Lcom/netease/newsreader/util/GroupAdapter;

.field private mTopView:Landroid/widget/FrameLayout;

.field private mTopViewCallback:Lcom/netease/newsreader/util/GroupListView$TopViewCallback;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 42
    invoke-direct {p0, p1}, Lcom/netease/newsreader/view/PullRefreshListView;-><init>(Landroid/content/Context;)V

    .line 25
    const/4 v0, -0x1

    iput v0, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    .line 43
    invoke-direct {p0, p1}, Lcom/netease/newsreader/util/GroupListView;->init(Landroid/content/Context;)V

    .line 44
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 1
    .parameter "context"
    .parameter "attrs"

    .prologue
    .line 37
    invoke-direct {p0, p1, p2}, Lcom/netease/newsreader/view/PullRefreshListView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 25
    const/4 v0, -0x1

    iput v0, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    .line 38
    invoke-direct {p0, p1}, Lcom/netease/newsreader/util/GroupListView;->init(Landroid/content/Context;)V

    .line 39
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 1
    .parameter "context"
    .parameter "attrs"
    .parameter "defStyle"

    .prologue
    .line 32
    invoke-direct {p0, p1, p2, p3}, Lcom/netease/newsreader/view/PullRefreshListView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 25
    const/4 v0, -0x1

    iput v0, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    .line 33
    invoke-direct {p0, p1}, Lcom/netease/newsreader/util/GroupListView;->init(Landroid/content/Context;)V

    .line 34
    return-void
.end method

.method private callTopViewUpdate(I)V
    .locals 3
    .parameter "group"

    .prologue
    .line 167
    iget-object v0, p0, Lcom/netease/newsreader/util/GroupListView;->mTopViewCallback:Lcom/netease/newsreader/util/GroupListView$TopViewCallback;

    if-eqz v0, :cond_0

    .line 168
    iget-object v0, p0, Lcom/netease/newsreader/util/GroupListView;->mTopViewCallback:Lcom/netease/newsreader/util/GroupListView$TopViewCallback;

    iget-object v1, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    const/4 v2, 0x0

    invoke-virtual {v1, v2}, Landroid/widget/FrameLayout;->getChildAt(I)Landroid/view/View;

    move-result-object v1

    invoke-interface {v0, v1, p1}, Lcom/netease/newsreader/util/GroupListView$TopViewCallback;->updateView(Landroid/view/View;I)V

    .line 170
    :cond_0
    return-void
.end method

.method private init(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 48
    return-void
.end method


# virtual methods
.method protected onFinishInflate()V
    .locals 4

    .prologue
    .line 52
    invoke-super {p0}, Lcom/netease/newsreader/view/PullRefreshListView;->onFinishInflate()V

    .line 54
    new-instance v1, Landroid/widget/FrameLayout;

    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-direct {v1, v2}, Landroid/widget/FrameLayout;-><init>(Landroid/content/Context;)V

    iput-object v1, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    .line 56
    new-instance v0, Landroid/widget/FrameLayout$LayoutParams;

    const/4 v1, -0x1

    .line 57
    const/4 v2, -0x2

    const/16 v3, 0x30

    .line 56
    invoke-direct {v0, v1, v2, v3}, Landroid/widget/FrameLayout$LayoutParams;-><init>(III)V

    .line 58
    .local v0, lp:Landroid/widget/FrameLayout$LayoutParams;
    iget-object v1, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {p0, v1, v0}, Lcom/netease/newsreader/util/GroupListView;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 60
    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getListView()Landroid/widget/ListView;

    move-result-object v1

    invoke-virtual {v1, p0}, Landroid/widget/ListView;->setOnScrollListener(Landroid/widget/AbsListView$OnScrollListener;)V

    .line 61
    return-void
.end method

.method protected onLayout(ZIIII)V
    .locals 6
    .parameter "changed"
    .parameter "left"
    .parameter "top"
    .parameter "right"
    .parameter "bottom"

    .prologue
    .line 71
    invoke-super/range {p0 .. p5}, Lcom/netease/newsreader/view/PullRefreshListView;->onLayout(ZIIII)V

    .line 72
    iget-object v3, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v3}, Landroid/widget/FrameLayout;->getVisibility()I

    move-result v3

    const/16 v4, 0x8

    if-eq v3, v4, :cond_0

    .line 73
    iget-object v3, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v3}, Landroid/widget/FrameLayout;->getLayoutParams()Landroid/view/ViewGroup$LayoutParams;

    move-result-object v1

    check-cast v1, Landroid/widget/FrameLayout$LayoutParams;

    .line 74
    .local v1, lp:Landroid/widget/FrameLayout$LayoutParams;
    iget v2, v1, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    .line 75
    .local v2, t:I
    iget-object v3, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v3}, Landroid/widget/FrameLayout;->getMeasuredHeight()I

    move-result v3

    add-int v0, v2, v3

    .line 76
    .local v0, b:I
    iget-object v3, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    const/4 v4, 0x0

    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getMeasuredWidth()I

    move-result v5

    invoke-virtual {v3, v4, v2, v5, v0}, Landroid/widget/FrameLayout;->layout(IIII)V

    .line 78
    .end local v0           #b:I
    .end local v1           #lp:Landroid/widget/FrameLayout$LayoutParams;
    .end local v2           #t:I
    :cond_0
    return-void
.end method

.method protected onMeasure(II)V
    .locals 6
    .parameter "widthMeasureSpec"
    .parameter "heightMeasureSpec"

    .prologue
    const/4 v3, 0x0

    .line 82
    invoke-super {p0, p1, p2}, Lcom/netease/newsreader/view/PullRefreshListView;->onMeasure(II)V

    .line 83
    iget-object v1, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    move-object v0, p0

    move v2, p1

    move v4, p2

    move v5, v3

    invoke-virtual/range {v0 .. v5}, Lcom/netease/newsreader/util/GroupListView;->measureChildWithMargins(Landroid/view/View;IIII)V

    .line 84
    return-void
.end method

.method public onScroll(Landroid/widget/AbsListView;III)V
    .locals 11
    .parameter "view"
    .parameter "firstVisibleItem"
    .parameter "visibleItemCount"
    .parameter "totalItemCount"

    .prologue
    .line 111
    const/4 v8, -0x1

    if-eq p2, v8, :cond_0

    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mGroupAdapter:Lcom/netease/newsreader/util/GroupAdapter;

    if-eqz v8, :cond_0

    .line 112
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mGroupAdapter:Lcom/netease/newsreader/util/GroupAdapter;

    invoke-virtual {v8}, Lcom/netease/newsreader/util/GroupAdapter;->getCount()I

    move-result v8

    if-eqz v8, :cond_0

    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getHeight()I

    move-result v8

    if-nez v8, :cond_2

    .line 113
    :cond_0
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    const/16 v9, 0x8

    invoke-virtual {v8, v9}, Landroid/widget/FrameLayout;->setVisibility(I)V

    .line 164
    :cond_1
    :goto_0
    return-void

    .line 116
    :cond_2
    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getListView()Landroid/widget/ListView;

    move-result-object v5

    .line 117
    .local v5, listView:Landroid/widget/ListView;
    move v0, p2

    .line 118
    .local v0, first:I
    const/4 v2, 0x0

    .local v2, i:I
    :goto_1
    if-lt v2, p3, :cond_3

    .line 125
    :goto_2
    invoke-virtual {v5}, Landroid/widget/ListView;->getHeaderViewsCount()I

    move-result v8

    add-int/lit8 v8, v8, 0x1

    if-ge v0, v8, :cond_5

    .line 126
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    const/16 v9, 0x8

    invoke-virtual {v8, v9}, Landroid/widget/FrameLayout;->setVisibility(I)V

    goto :goto_0

    .line 119
    :cond_3
    invoke-virtual {v5, v2}, Landroid/widget/ListView;->getChildAt(I)Landroid/view/View;

    move-result-object v8

    invoke-virtual {v8}, Landroid/view/View;->getBottom()I

    move-result v8

    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getRefreshHeight()I

    move-result v9

    if-le v8, v9, :cond_4

    .line 120
    add-int/2addr v0, v2

    .line 121
    goto :goto_2

    .line 118
    :cond_4
    add-int/lit8 v2, v2, 0x1

    goto :goto_1

    .line 130
    :cond_5
    invoke-virtual {v5}, Landroid/widget/ListView;->getHeaderViewsCount()I

    move-result v8

    add-int/lit8 v8, v8, 0x1

    sub-int/2addr v0, v8

    .line 131
    invoke-virtual {v5}, Landroid/widget/ListView;->getHeaderViewsCount()I

    move-result v8

    add-int/lit8 v8, v8, 0x1

    sub-int/2addr p2, v8

    .line 133
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    const/4 v9, 0x0

    invoke-virtual {v8, v9}, Landroid/widget/FrameLayout;->setVisibility(I)V

    .line 135
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mGroupAdapter:Lcom/netease/newsreader/util/GroupAdapter;

    invoke-virtual {v8, v0}, Lcom/netease/newsreader/util/GroupAdapter;->getRealPosition(I)Lcom/netease/newsreader/util/GroupAdapter$ItemPosition;

    move-result-object v3

    .line 137
    .local v3, itemPosition:Lcom/netease/newsreader/util/GroupAdapter$ItemPosition;,"Lcom/netease/newsreader/util/GroupAdapter$ItemPosition;"
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v8}, Landroid/widget/FrameLayout;->getLayoutParams()Landroid/view/ViewGroup$LayoutParams;

    move-result-object v6

    check-cast v6, Landroid/widget/FrameLayout$LayoutParams;

    .line 138
    .local v6, lp:Landroid/widget/FrameLayout$LayoutParams;
    iget v8, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    iget v9, v3, Lcom/netease/newsreader/util/GroupAdapter$ItemPosition;->group:I

    if-eq v8, v9, :cond_6

    .line 139
    iget v8, v3, Lcom/netease/newsreader/util/GroupAdapter$ItemPosition;->group:I

    iput v8, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    .line 140
    iget v8, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    invoke-direct {p0, v8}, Lcom/netease/newsreader/util/GroupListView;->callTopViewUpdate(I)V

    .line 141
    const/4 v8, 0x0

    iput v8, v6, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    .line 142
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v8}, Landroid/widget/FrameLayout;->requestLayout()V

    goto :goto_0

    .line 144
    :cond_6
    iget v8, v3, Lcom/netease/newsreader/util/GroupAdapter$ItemPosition;->pos:I

    iget-object v9, p0, Lcom/netease/newsreader/util/GroupListView;->mGroupAdapter:Lcom/netease/newsreader/util/GroupAdapter;

    iget v10, p0, Lcom/netease/newsreader/util/GroupListView;->mCurrentGroup:I

    invoke-virtual {v9, v10}, Lcom/netease/newsreader/util/GroupAdapter;->getChildrenCount(I)I

    move-result v9

    add-int/lit8 v9, v9, -0x1

    if-lt v8, v9, :cond_8

    .line 145
    invoke-virtual {v5}, Landroid/widget/ListView;->getLayoutParams()Landroid/view/ViewGroup$LayoutParams;

    move-result-object v4

    check-cast v4, Landroid/widget/FrameLayout$LayoutParams;

    .line 146
    .local v4, l:Landroid/widget/FrameLayout$LayoutParams;
    sub-int v8, v0, p2

    invoke-virtual {p1, v8}, Landroid/widget/AbsListView;->getChildAt(I)Landroid/view/View;

    move-result-object v8

    invoke-virtual {v8}, Landroid/view/View;->getBottom()I

    move-result v8

    .line 147
    iget v9, v4, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    .line 146
    add-int v1, v8, v9

    .line 148
    .local v1, firstBottom:I
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v8}, Landroid/widget/FrameLayout;->getHeight()I

    move-result v7

    .line 150
    .local v7, topHeight:I
    if-ge v1, v7, :cond_7

    .line 151
    sub-int v8, v1, v7

    iput v8, v6, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    .line 152
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v8}, Landroid/widget/FrameLayout;->requestLayout()V

    goto/16 :goto_0

    .line 153
    :cond_7
    iget v8, v6, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    if-eqz v8, :cond_1

    .line 154
    const/4 v8, 0x0

    iput v8, v6, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    .line 155
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v8}, Landroid/widget/FrameLayout;->requestLayout()V

    goto/16 :goto_0

    .line 158
    .end local v1           #firstBottom:I
    .end local v4           #l:Landroid/widget/FrameLayout$LayoutParams;
    .end local v7           #topHeight:I
    :cond_8
    iget v8, v6, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    if-eqz v8, :cond_1

    .line 159
    const/4 v8, 0x0

    iput v8, v6, Landroid/widget/FrameLayout$LayoutParams;->topMargin:I

    .line 160
    iget-object v8, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v8}, Landroid/widget/FrameLayout;->requestLayout()V

    goto/16 :goto_0
.end method

.method public onScrollStateChanged(Landroid/widget/AbsListView;I)V
    .locals 0
    .parameter "view"
    .parameter "scrollState"

    .prologue
    .line 175
    return-void
.end method

.method public setAdapter(Lcom/netease/newsreader/util/GroupAdapter;)V
    .locals 1
    .parameter "adapter"

    .prologue
    .line 88
    iput-object p1, p0, Lcom/netease/newsreader/util/GroupListView;->mGroupAdapter:Lcom/netease/newsreader/util/GroupAdapter;

    .line 89
    invoke-virtual {p0}, Lcom/netease/newsreader/util/GroupListView;->getListView()Landroid/widget/ListView;

    move-result-object v0

    invoke-virtual {v0, p1}, Landroid/widget/ListView;->setAdapter(Landroid/widget/ListAdapter;)V

    .line 90
    return-void
.end method

.method public setTopViewCallback(Lcom/netease/newsreader/util/GroupListView$TopViewCallback;)V
    .locals 4
    .parameter "callback"

    .prologue
    .line 93
    iput-object p1, p0, Lcom/netease/newsreader/util/GroupListView;->mTopViewCallback:Lcom/netease/newsreader/util/GroupListView$TopViewCallback;

    .line 94
    if-eqz p1, :cond_1

    .line 95
    iget-object v2, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v2}, Landroid/widget/FrameLayout;->removeAllViews()V

    .line 96
    invoke-interface {p1}, Lcom/netease/newsreader/util/GroupListView$TopViewCallback;->createView()Landroid/view/View;

    move-result-object v1

    .line 97
    .local v1, top:Landroid/view/View;
    if-eqz v1, :cond_1

    .line 98
    invoke-virtual {v1}, Landroid/view/View;->getLayoutParams()Landroid/view/ViewGroup$LayoutParams;

    move-result-object v0

    check-cast v0, Landroid/widget/FrameLayout$LayoutParams;

    .line 99
    .local v0, lp:Landroid/widget/FrameLayout$LayoutParams;
    if-nez v0, :cond_0

    .line 100
    new-instance v0, Landroid/widget/FrameLayout$LayoutParams;

    .end local v0           #lp:Landroid/widget/FrameLayout$LayoutParams;
    const/4 v2, -0x1

    const/4 v3, -0x2

    invoke-direct {v0, v2, v3}, Landroid/widget/FrameLayout$LayoutParams;-><init>(II)V

    .line 102
    .restart local v0       #lp:Landroid/widget/FrameLayout$LayoutParams;
    :cond_0
    iget-object v2, p0, Lcom/netease/newsreader/util/GroupListView;->mTopView:Landroid/widget/FrameLayout;

    invoke-virtual {v2, v1, v0}, Landroid/widget/FrameLayout;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 106
    .end local v0           #lp:Landroid/widget/FrameLayout$LayoutParams;
    .end local v1           #top:Landroid/view/View;
    :cond_1
    return-void
.end method
